from dotenv import load_dotenv
from openai import OpenAI

import pandas as pd

file_path = "sales_data.csv"

sales_data = pd.read_csv(file_path)

# print(sales_data)

load_dotenv()
#
client = OpenAI()

file = client.files.create(
    file=open(file_path, "rb"),
    purpose="assistants"
)

print(file) #  file_id : file-bblx99gKnQodPHNgCIewtoOV

assistant = client.beta.assistants.create(

    instructions="作为一个数据科学助理，当给定数据和一个查询时，你能编写适当的代码并创建适当的可视化",
    model="gpt-4-turbo",
    tools=[{"type": "code_interpreter"}],

    tool_resources={
        "code_interpreter": {
            "file_ids": [file.id]
        }
    },

)

print(assistant)  #    assistant_id 是 asst_GXLXEzFlbzQ8rjVUCqhQJRcC
